package frist50;

public class T0014 {
    public String longestCommonPrefix(String[] strs) {
        int minLen=Integer.MAX_VALUE;
        for (int i = 0; i <strs.length ; i++) {
            minLen=Math.min(minLen,strs[i].length());
        }
        int i=0;
        String s="";
        while (i<minLen){
            boolean b=true;
            for (int j = 1; j <strs.length ; j++) {
                if (strs[j].charAt(i)!=strs[0].charAt(i)){
                    b=false;
                    break;
                }
            }
            if (!b)return s;
            s+=strs[0].charAt(i);
            i++;
        }
        return s;
    }
}
